package org

import (
	"dhfshop/models/org"
	"dhfshop/controllers/base"
)

// 资源控制
type ResourceController struct {
	base.BaseController
}

// 获取所有的资源API
func (this *ResourceController) GetAllResources() {
	query,_,fields,order_by,offset,limit,err := this.GetQueryPara()
	if err != nil {
	   this.ServeError(err.Error())
	   return
	}
	list, cnt, err := org.GetAllResources(query,fields,order_by,offset,limit)
	if err != nil {
	    this.ServeError(err.Error())
	    return
	}
	/*
	var orderVersion string
	if this.CurrentUser != nil {
	    orderVersion = this.CurrentUser.OrderVersion
	}
	list, err := org.GetResByOrderVersion(orderVersion, 0, 200)
	if err != nil {
	    this.ServeError(err.Error())
	    return
	}
	cnt := len(list)
	*/
	r := struct {
		TotalCount   int             `json:"total_count"`
		Resources    []*org.Resource `json:"resources"`
	}{TotalCount: int(cnt), Resources: list}
	this.Data["json"] = r
	this.ServeJSON()
}


